use  std::collections::HashMap;
impl Solution {
    pub fn is_n_straight_hand(mut hand: Vec<i32>, group_size: i32) -> bool {
        hand.sort();
        let mut new_arr=Vec::with_capacity(hand.len());
        let mut mp:HashMap<i32,i32>=std::collections::HashMap::new();
        let mut last_val=hand[0];
        new_arr.push(last_val);
        let mut count =0;
        for val in hand{
            if last_val==val{
                count+=1;
            }else{
                mp.insert(last_val, count);
                last_val=val;
                count=1;
                new_arr.push(val);
            }
        }
        mp.insert(last_val, count);
        for i in 0..new_arr.len(){
            if let Some(&count)=mp.get(&new_arr[i]){
                if count!=0{
                    if new_arr.len()-i<group_size as usize{
                        return false
                    }
                    for j in 1..group_size {
                        if let Some(&count1)=mp.get(&(new_arr[i]+j)){
                            if count1<count{
                                return  false;
                            }else{
                                mp.insert(new_arr[i]+j, count1-count);
                            }
                        }else{
                            return false;
                        }
                    }
                }
            }
        }

        true
    }
}